package cn.abdl.springsecurity.controller;

import cn.abdl.springsecurity.utiils.SecurityUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;

@Controller
public class IndexController {
    private Logger logger = LoggerFactory.getLogger(IndexController.class);

    @RequestMapping("/index")
    public String index(HttpServletRequest request, Model model){
        if (SecurityUtil.userHasAuthority("admin")){
            return "/views/admin.html";
        }
        return "/views/index.html";
    }
    @RequestMapping("/login")
    public String login(){
        return "/views/login.html";
    }
    @RequestMapping("/logout")
    public String logout(){
        return "/views/register.html";
    }
    @RequestMapping("/reset")
    public String reset(){
        return "/views/reset.html";
    }
    @RequestMapping("/register")
    public String register(){
        return "/views/register.html";
    }


}
